package de.lehmann.sudoku.data;

@SuppressWarnings("unused") //TODO: Remove suppression of "unused" warnings from Tile
/**
 * A single Square
 * which one number can be written into <br>
 * 
 */
public class Tile{
	/**
	 * The number of Tags set on this Field
	 */
	private int tagCount;
	/**
	 * This Fields tags
	 */
	private boolean[] tags;
	/**
	 * This Fields main Value <br>
	 * -1 means it is not set
	 */
	private int value;
	
	public Tile() {
		value = -1;
		tagCount = 0;
		boolean[] tags = {false, false, false, false, false, false, false, false, false};
		this.tags = tags;
	}
	
	public Tile(int value) {
		this.value = value;
		tagCount = 0;
		boolean[] tags = {false, false, false, false, false, false, false, false, false};
		this.tags = tags;
	}

	public Tile(boolean generating) {
		value = -1;
		tagCount = generating? 9 : 0;
		boolean[] tags = {generating, generating, generating, generating, generating, generating, generating, generating, generating};
		this.tags = tags;
	}
	
	/**
	 * Sets this Fields value
	 * @param value - An integer between 1 and 9
	 */
	public void setValue(int value) {
		this.value = value;
	}
	
	/**
	 * Get this Fields set value
	 * @return <b>1-9</b> if value is set, or<br>
	 * <b>-1</b> if it is not set
	 */
	public int getValue() {
		return value;
	}
	
	
	public void clearValue() {
		value = 0;
	}
	
	public void setTag(int index) {
		if(!this.tags[index-1]) {
			this.tagCount++;
			this.tags[index-1] = true;
		}
	}
	
	public boolean getTag(int index) {
		return this.tags[index-1];
	}
	
	public void clearTag(int index) {
		this.tagCount--;
		this.tags[index] = false;
	}
	
	
}
